#!/usr/bin/perl
use DBI;
my $tmp = time - 2160000;
my $dbh=DBI->connect("DBI:mysql:csworld:127.0.0.1","tonberry","kewlnet");
my $time = time;
my @nicktodelete;
my $sth=$dbh->prepare("SELECT rnick FROM nicks WHERE lastseen =< $tmp");
$sth->execute;
while ($tmp = $sth->fetchrow_array) {
    push @nicktodelete, $tmp;
    print "$tmp\n";
}
my $result = <STDIN>;
foreach (@nicktodelete) {
    $sth=$dbh->prepare("DELETE FROM nicks WHERE rnick = '$_';");
    $sth->execute;
    $sth=$dbh->prepare("DELETE FROM users WHERE rnick = '$_';");
    $sth->execute;
    $sth=$dbh->prepare("DELETE FROM channels where owner = '$_';");
    $sth->execute;
}


#time - 216000 > x
